{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "slide_helper": "subslide_end",
     "slide_type": "subslide"
    },
    "slide_helper": "slide_end",
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Scientific Programming in Python (SPiP) - Exercises for Programming Basics\n",
    "\n",
    "by [Michael Granitzer (michael.granitzer@uni-passau.de)](http://www.mendeley.com/profiles/michael-granitzer/) \n",
    "\n",
    "[Konstantin Ziegler (konstantin.ziegler@uni-passau.de)](http://zieglerk.net)\n",
    "   \n",
    "__License__\n",
    "\n",
    "This work is licensed under a [Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "slide_helper": "subslide_end",
     "slide_type": "subslide"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Exercises \n",
    "\n",
    "Use the [Python 101 Cheatsheet](http://nbviewer.ipython.org/urls/bitbucket.org/hrojas/learn-pandas/raw/master/lessons/Python_101.ipynb) as reference\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "slide_helper": "subslide_end",
     "slide_type": "subslide"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "# Exercise 2.1.a: Data Structures\n",
    "  \n",
    "Given is the following table with data on when someone likes to play tennis.\n",
    "\n",
    "<table border=\"\" cellspacing=\"0\" width=\"48%\">\n",
    "  <tbody><tr>\n",
    "      <td><b>Day</b></td>\n",
    "      <td><b>outlook</b></td>\n",
    "      <td><b>temperature</b></td>\n",
    "      <td><b>humidity</b></td>\n",
    "      <td><b>windy</b></td>\n",
    "      <td><b>play</b></td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>1</td>\n",
    "      <td>sunny</td>\n",
    "      <td>85</td>\n",
    "\n",
    "      <td>85</td>\n",
    "\n",
    "      <td>false</td>\n",
    "\n",
    "      <td>no</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>2</td>\n",
    "\n",
    "      <td>sunny</td>\n",
    "\n",
    "      <td>80</td>\n",
    "\n",
    "      <td>90</td>\n",
    "\n",
    "      <td>true</td>\n",
    "\n",
    "      <td>no</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>3</td>\n",
    "\n",
    "      <td>overcast</td>\n",
    "\n",
    "      <td>83</td>\n",
    "\n",
    "      <td>86</td>\n",
    "\n",
    "      <td>false</td>\n",
    "\n",
    "      <td>yes</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>4</td>\n",
    "\n",
    "      <td>rainy</td>\n",
    "\n",
    "      <td>70</td>\n",
    "\n",
    "      <td>96</td>\n",
    "\n",
    "      <td>false</td>\n",
    "\n",
    "      <td>yes</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>5</td>\n",
    "\n",
    "      <td>rainy</td>\n",
    "\n",
    "      <td>68</td>\n",
    "\n",
    "      <td>80</td>\n",
    "\n",
    "      <td>false</td>\n",
    "\n",
    "      <td>yes</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>6</td>\n",
    "\n",
    "      <td>rainy</td>\n",
    "\n",
    "      <td>65</td>\n",
    "\n",
    "      <td>70</td>\n",
    "\n",
    "      <td>true</td>\n",
    "\n",
    "      <td>no</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>7</td>\n",
    "\n",
    "      <td>overcast</td>\n",
    "\n",
    "      <td>64</td>\n",
    "\n",
    "      <td>65</td>\n",
    "\n",
    "      <td>true</td>\n",
    "\n",
    "      <td>yes</td>\n",
    "    </tr>\n",
    "    </tbody>\n",
    "</table>\n",
    "\n",
    "\n",
    "* Represent the following table using Python build-in data structures.\n",
    "* Given that data structure, print \n",
    "  - Print the first two and the last two entries in the table\n",
    "  - Remove every second row\n",
    "  - Print all lines with outlook sunny"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "slide_helper": "subslide_end",
     "slide_type": "subslide"
    },
    "slide_helper": "slide_end",
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Exercise 2.1.b: Data Analysis with Python Data Structures\n",
    "\n",
    "Use the weather data from the exercise on data structures and complete the following tasks:\n",
    "\n",
    "1. Write a function to count the distribution of the values in a column. The output should be a dictionary (e.g. f(column play)={\"yes\":7,\"no\":3})\n",
    "2. Write a function to filter out rows on a specific attribute and an abritrary criterion (e.g. f(column play=\"yes)==> only rows where play is yes)\n",
    "3. Write a function that eliminates particular columns\n",
    "\n",
    "Given this function, conduct the following analysis:\n",
    "\n",
    "1. How often do you play tennis independent of the other attributes?\n",
    "2. How often do you play tennis when it is \"sunny\"?\n",
    "3. Compare the average, minimum and maximum temperature when you play tennis?\n",
    "4. Compare the average, minimum and maximum humidity when you play tennis?\n",
    "5. Plot the an scatter plot (x,y diagramm) of humidity (x) and temperatur (y) when you play tennis compared to when you do not play tennis. Use the following lines of code for a plot:\n",
    "\n",
    "     <pre><code>\n",
    "     %pylab inline\n",
    "     from pylab import *\n",
    "     figure()\n",
    "     plot(xdata,ydata)\n",
    "     title(\"Title goes here\")\n",
    "     show()</code></pre>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "slide_helper": "subslide_end",
     "slide_type": "subslide"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Solutions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "slide_type": "subslide"
    },
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Solution 2.1.a: Data Structures\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "internals": {
     "frag_number": 6,
     "slide_helper": "subslide_end"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Data:\n",
      "[[1, 'sunny', 85, 85, 'false', 'no'], [2, 'sunny', 80, 90, True, 'no'], [3, 'overcast', 83, 86, False, 'yes'], [4, 'rainy', 70, 96, False, 'yes'], [5, 'rainy', 68, 80, False, 'yes'], [6, 'rainy', 65, 70, True, 'no'], [7, 'overcast', 64, 65, True, 'yes']]\n"
     ]
    }
   ],
   "source": [
    "labels = [\"Day\",\"outlook\",\"temperature\",\"humidity\",\"windy\",\"play\"]\n",
    "data = [[1,\"sunny\",85,85,\"false\",\"no\"]\n",
    "       ,[2,\"sunny\",80,90,True,\"no\"]\n",
    "       ,[3,\"overcast\",83,86,False,\"yes\"]\n",
    "       ,[4,\"rainy\",70,96,False,\"yes\"]\n",
    "       ,[5,\"rainy\",68,80,False,\"yes\"]\n",
    "       ,[6,\"rainy\",65,70,True,\"no\"]\n",
    "       ,[7,\"overcast\",64,65,True,\"yes\"]]\n",
    "print(\"The Data:\")\n",
    "print(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "------------------------------------------------\n",
      "Printing first two and last two items\n",
      "[[1, 'sunny', 85, 85, 'false', 'no'], [2, 'sunny', 80, 90, True, 'no']] \n",
      "\n",
      "[[6, 'rainy', 65, 70, True, 'no'], [7, 'overcast', 64, 65, True, 'yes']]\n",
      "------------------------------------------------\n",
      "Removing every second line\n",
      "[[1, 'sunny', 85, 85, 'false', 'no'], [3, 'overcast', 83, 86, False, 'yes'], [5, 'rainy', 68, 80, False, 'yes'], [7, 'overcast', 64, 65, True, 'yes']]\n",
      "------------------------------------------------\n",
      "Showing all remaining records with outlook sunny\n",
      "[[1, 'sunny', 85, 85, 'false', 'no']]\n"
     ]
    }
   ],
   "source": [
    "print(\"------------------------------------------------\")\n",
    "print(\"Printing first two and last two items\")\n",
    "print(data[0:2], \"\\n\")\n",
    "print(data[-2:])\n",
    "print(\"------------------------------------------------\")\n",
    "print(\"Removing every second line\")\n",
    "del data[1::2]\n",
    "print(data)\n",
    "print(\"------------------------------------------------\")\n",
    "print(\"Showing all remaining records with outlook sunny\")\n",
    "print([ i for i in data if i[1]==\"sunny\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 6,
     "slide_type": "subslide"
    },
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Solution 2.1.b: Data Analysis with Python Data Structures\n",
    "\n",
    "**First**, the function definition\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 8,
     "slide_helper": "subslide_end"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "#imperative style\n",
    "def distribution(fn_val,data):\n",
    "    \"\"\"\n",
    "      fn_val is a function selecting the column to count\n",
    "      data is the data set itself\n",
    "    \"\"\"\n",
    "    dist = {}\n",
    "    for row in data:\n",
    "        val = fn_val(row)\n",
    "        if val in dist.keys():\n",
    "           dist[val]+=1\n",
    "        else:\n",
    "           dist[val]=1\n",
    "    return dist\n",
    "\n",
    "#more functional style - the Pythonian way\n",
    "def distribution2(fn_val,data):\n",
    "    vals = [fn_val(row) for row in data]\n",
    "    return {x:vals.count(x) for x in vals}\n",
    "\n",
    "def slice_it(fn_select,data,indizes):\n",
    "    \"\"\"\n",
    "      creates a sub nested list from data by selecting rows (fn_select) and columns )(indices)\n",
    "      fn_select is a function f(row)--> Bool for selecting the row\n",
    "      data is the data set itself\n",
    "      indizes is the column indices that should be contained in the returned array.\n",
    "    \"\"\"\n",
    "    rows =[row for row in data if fn_select(row)]\n",
    "    return [[row[i] for i in indizes ] for row in rows]\n",
    "\n",
    "def unfold(a_list):\n",
    "    return [item for sublist in a_list for item in sublist]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 8,
     "slide_type": "subslide"
    },
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "**Second** the data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 10,
     "slide_helper": "subslide_end"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "data = [[1,\"sunny\",85,85,\"false\",\"no\"]\n",
    "       ,[2,\"sunny\",80,90,True,\"no\"]\n",
    "       ,[3,\"overcast\",83,86,False,\"yes\"]\n",
    "       ,[4,\"rainy\",70,96,False,\"yes\"]\n",
    "       ,[5,\"rainy\",68,80,False,\"yes\"]\n",
    "       ,[6,\"rainy\",65,70,True,\"no\"]\n",
    "       ,[7,\"overcast\",64,65,True,\"yes\"]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 10,
     "slide_type": "subslide"
    },
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "**Third,** calculate distributions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 12,
     "slide_helper": "subslide_end"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I play tennis  4  days out of  7\n",
      "I play tennis  4  days out of  7\n",
      "I played tennis 0 times when it is sunny\n"
     ]
    }
   ],
   "source": [
    "print(\"I play tennis \", distribution2(lambda x:x[5],data)[\"yes\"], \" days out of \", len (data))\n",
    "print(\"I play tennis \", distribution(lambda x:x[5],data)[\"yes\"], \" days out of \", len (data))\n",
    "sunny_and_play = distribution(lambda x:x[0],slice_it(lambda x:x[1]==\"sunny\", data,[5]))\n",
    "if not \"yes\" in sunny_and_play.keys():\n",
    "    sunny_and_play[\"yes\"]=0\n",
    "print(\"I played tennis %d times when it is sunny\"% sunny_and_play[\"yes\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 12,
     "slide_type": "subslide"
    },
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "**Fourth**, slice and calculate aggregations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 14,
     "slide_helper": "subslide_end"
    },
    "slide_helper": "subslide_end",
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I love playing tennis when it is warmer than 64.000000 but colder than 83.000000. Best is at 71.250000\n",
      "I love playing tennis when it is less humid than 65.000000 but more humid than 96.000000. Best is at 81.750000\n"
     ]
    }
   ],
   "source": [
    "playing = unfold(slice_it(lambda x:x[5]==\"yes\", data,[2]))\n",
    "min_val= min(playing)\n",
    "max_val=max(playing)\n",
    "sum_val=sum(playing)/len(playing)\n",
    "print(\"I love playing tennis when it is warmer than %f but colder than %f. Best is at %f\"%(min_val , max_val,sum_val))\n",
    "\n",
    "playing = unfold(slice_it(lambda x:x[5]==\"yes\", data,[3]))\n",
    "min_val= min(playing)\n",
    "max_val=max(playing)\n",
    "sum_val=sum(playing)/len(playing)\n",
    "print(\"I love playing tennis when it is less humid than %f but more humid than %f. Best is at %f\"%(min_val , max_val,sum_val))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 14,
     "slide_type": "subslide"
    },
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "**Finally**, do the plotting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false,
    "internals": {
     "frag_helper": "fragment_end",
     "frag_number": 16,
     "slide_helper": "subslide_end"
    },
    "slide_helper": "slide_end",
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEKCAYAAADpfBXhAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFktJREFUeJzt3X2QZXV95/H3RwcfwHEEFRBlUbKizriibowWCmkjZTS7\ngkqtDxgj6gZ3N0RjwRYMtQawsqa0ViqplKRAtEVXUXlQwfWBZbF9KhIXwcVhEEdBGCCMPNuCisB3\n/zhn4NJ2T9+e7p7b98f7VdXV5557Hr73Nz2f+zu/c869qSokSW15xKgLkCQtPcNdkhpkuEtSgwx3\nSWqQ4S5JDTLcJalBhrsWLMn6JKdt4/lrkvzRMMtKWh6GewMGw3Rg3tuSfHs59ldVf1tVRy502ST7\nJLk/yYr4u0tyeJLpJL9IcneS+/rp6SS/GHV9i5Hkj5NsGnUdGp0V8Z9My2al3aEWupoy6kIAquoz\nVbW6qh4PvBq4oaoePzBvRUpvvsVYxL9/kkdu77paGQz3h4m+x7zvwOPJJO/vp/8wyeYk/zXJliQ3\nJDk0yauTXJXkliTrB9Y9IcmnBh6/NcnPktyc5PgZ+z0hySf7h9/sf9/R95APSnJrknUDyz85yV1J\nnjhjO49KcnuStQPzntT3uJ+U5IlJzu+XuTXJN1kCSZ6W5Iv9a/tJkncNPPe3Sf5nks/2vf1Lkzw9\nyV/3y1+d5A8Hlr84yfuTXNLXeVaS1QPPH5jkn/rnLklywIx1T0ryT8BdwFOSHJnkyr4tf5zk7f2y\nuwHnAvsOHJnsmuTMwX+fmb37JP+S5OgkG4A7+3l7z/X6tbIZ7u2a2bObrxe3J/AoYC/gBOCjwFuA\nFwAHAe9Lss/M7fVhe0q/7F7AE4GnzrGPg/rfj+97yN8CzgT+dGCZNwMXVtWtDym+6h7gnP75rd4A\nT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vO3nsaj2Xspwvx7YXFWX9I/PBl5QVTcPjA19lG7caCV7\nNfD9qrqlf7wl3Y1cpLtZ6+cjq2w4W+u/GWCM2v9g4Oqquq0/tP4CcADj0/4z6z8XOGBc2r+qJqvq\n96tqArgDuIrxafvZ6v/xuLT9gLna+wa6I6mtnsaDQ35zWrJw7w8nNifZr5/1CmBjX+RWr6c7hFrJ\n3sxDhzTOo7tZC7Zxs9YK8pD6x6j9rwNekuQxSUL/98P4tP9s9V85Lu2f5Mn9738FvI5uWHJc2n7W\n+seg7cNDzwnM1d7nAW/qrx57BvCvge/Nu/WqWrIfuo8D/r/AD+h6LmuATwKX9/O+SDeOt6T7XcL6\ndwZuBlYPzNuN7uz0VcAFwBNGXecC6x+n9j8BuLKv9wy6m+bGqf0H6/9EX/9YtD/dScgNdEMaE/28\ncWr72epfsW1P9+Z5I/Abuo7B24Fd52pvuo9U/0n/9/XKYfbhTUyS1CC/Zk+SGmS4S1KDDHdJapDh\nLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUoP8PiI8/YhwcJLMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fb3143fa898>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline \n",
    "import matplotlib.pyplot as plt #load plotting library\n",
    "plt.figure()\n",
    "plt.plot(unfold(slice_it(lambda x:x[5]==\"yes\", data,[3])),unfold(slice_it(lambda x:x[5]==\"yes\", data,[2])),\".\")\n",
    "plt.plot(unfold(slice_it(lambda x:x[5]==\"no\", data,[3])),unfold(slice_it(lambda x:x[5]==\"no\", data,[2])),\"*\")\n",
    "plt.title(\"Humidity vs. Temperature\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
